package com.yanqu.road.dao.impl.log;

import com.yanqu.road.dao.db.DbNameStrategy;
import com.yanqu.road.dao.db.DbParameter;
import com.yanqu.road.dao.impl.TempDao;
import com.yanqu.road.entity.log.LogWasheOperate;

import java.sql.Types;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class LogWasheOperateDaoImpl extends TempDao {

    public boolean addLogWasheOperateList(List<LogWasheOperate> list) {
        boolean result = false;
        getDb().setConnName(DbNameStrategy.getChannelServerDb());
        String sql = "INSERT INTO t_n_log_washe_operate(userId,opponentUserId,roomId,type,param,time,round,modeId,sceneId,step,cardMp,score) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)";
        List<Map<Integer, DbParameter>> mapList = new ArrayList<>();
        for (LogWasheOperate data : list) {
            Map<Integer, DbParameter> para = new HashMap<>();
            int i = 1;
            para.put(i++, new DbParameter(Types.BIGINT, data.getUserId()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getOpponentUserId()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getRoomId()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getType()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getParam()));
            para.put(i++, new DbParameter(Types.TIMESTAMP, data.getTime()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getRound()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getModeId()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getSceneId()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getStep()));
            para.put(i++, new DbParameter(Types.INTEGER, data.getCardMp()));
            para.put(i++, new DbParameter(Types.BIGINT, data.getScore()));
            mapList.add(para);
        }
        if (getDb().executeBatchQuery(sql, mapList) > -1) {
            result = true;
        }
        return result;
    }

}
